package com.tza.web.t_net.shared.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

public class DataMap implements Serializable
{

   /**
    * 
    */
   private static final long serialVersionUID = 268486690317456741L;
   private List<Data>        dataList         = new ArrayList<Data>();

   public final List<Data> getDataList()
   {
      return dataList;
   }

   public final void setDataList(List<Data> dataList)
   {
      this.dataList = dataList;
   }

   public final void put(String key, String value)
   {
      Data data = new Data();
      data.setKey(key);
      data.setValue(value);
      dataList.add(data);
   }

   public final Object get(String key)
   {
      for (Data data : dataList)
      {
         if (data.getKey() != null && data.getKey().equals(key))
         {

            return data.getValue();

         }
      }
      return null;
   }

   public final void putAll(Map<String, String> map)
   {

      if (map != null)
      {
         for (Entry<String, String> ent : map.entrySet())
         {
            this.put((String) ent.getKey(), ent.getValue());
         }
      }

   }

   public void put(String key, DataMap value)
   {
      Data data = new Data();
      data.setKey(key);
      data.setValue(value);
      dataList.add(data);

   }

}
